<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type='text/javascript' src='../vue.js'></script>
    
</head>
<body>
    <!-- 通过插值实现 -->
    <!-- <div id="root">
        <h1>联动小案例</h1>
        姓: <input type="text" placeholder="输入姓" v-model="xing"></input>
        <br>
        名: <input type="text" placeholder="输入名" v-model="ming"></input>
        <hr>
        姓名:{{xing}}-{{ming}}
    </div>
    <script type='text/javascript'>
        new Vue({ 
            el: '#root',
            data: {
                key:"value",
                xing:"",
                ming:""
            }
        })
    </script> -->
 <!-- 通过method实现 -->
    <!-- <div id="root">
        <h1>联动小案例</h1>
        姓: <input type="text" placeholder="输入姓" v-model="xing"></input>
        <br>
        名: <input type="text" placeholder="输入名" v-model="ming"></input>
        <hr>
        姓名:{{getName()}}
    </div>
    <script type='text/javascript'>
        new Vue({ 
            el: '#root',
            data: {
                key:"value",
                xing:"",
                ming:""
            },
            methods: {
                getName(){
                    return this.xing + "-" + this.ming
                }
            },
        })
    </script> -->
 <!-- 通过computed属性实现 -->
    <div id="root">
        <h1>联动小案例</h1>
        姓: <input type="text" placeholder="输入姓" v-model="xing"></input>
        <br>
        名: <input type="text" placeholder="输入名" v-model="ming"></input>
        <hr>
        姓名:{{fullName}}
    </div>
    <script type='text/javascript'>
        new Vue({ 
            el: '#root',
            data: {
                key:"value",
                xing:"",
                ming:""
            },
            methods: {
                getName(){
                    return this.xing + "-" + this.ming
                }
            },
            computed:{
                fullName(){
                    return this.xing + "-" + this.ming
                }
            }
        })
    </script>
</body>
</html>